package com.example.tests;

import java.io.File;
import java.io.FileReader;
import java.util.Properties;

import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;

import com.example.fw.ApplicationManager;

public class TestBase {
	
	protected static ApplicationManager app;

	@BeforeTest
	public void setUp() throws Exception {
		String confgiFile = System.getProperty("configFile", "application.properties");
		Properties properties = new Properties();
		properties.load(new FileReader(new File(confgiFile)));
		app = new ApplicationManager(properties);
	}
	
	@AfterTest
	public void tearDown() throws Exception {
		app.stop();

	}

/*	@DataProvider	
	public Iterator<Object[]> randomValidGroupGenerator(){
		List<GroupData> groups = generateRandomGroups(5);
		return wrapGroupsForDataProvider(groups).iterator();
	}

	public static List<Object[]> wrapGroupsForDataProvider(List<GroupData> groups) {
		List<Object[]> list = new ArrayList<Object[]>();
		for (GroupData group : groups) {
			list.add(new Object[]{group});
		}
		return list;
	}

	public static List<Object[]> wrapContactsForDataProvider(List<ContactData> contacts) {
		List<Object[]> list = new ArrayList<Object[]>();
		for (ContactData contact : contacts) {
			list.add(new Object[]{contact});
		}
		return list;
	}
	
	@DataProvider	
	public Iterator<Object[]> randomValidContactGenerator(){
		List<ContactData> list = generateRandomContacts(5);
		return wrapContactsForDataProvider(list).iterator();
	}
	*/
}
